package pl.com.qapps.unity;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import pl.com.qapps.unity.UnityPb.Response;

/**
 * @author Jakub Dykowski
 * 
 */
public class UnityTest {
	public static void main(String[] args) throws IllegalStateException,
			IOException, InterruptedException {
		try {
			System.out.printf("Unity is supported: %s\n", Unity.isSupported());
			Unity.register(new Unity.SignalHandler() {

				@Override
				public void onSignal(Response res) {
					System.out.printf("Unity signal received: %s\n",
							res.toString());
				}
			});
			UnityLauncher eclipse = UnityLauncher
					.getForDesktopFile("Eclipse.desktop");
			System.out.println(eclipse);
			eclipse.setUrgent(true);
			eclipse.setCountVisible(true);
			eclipse.setCount(3);
			TimeUnit.SECONDS.sleep(1);
			eclipse.setUrgent(false);
			TimeUnit.SECONDS.sleep(2);
			eclipse.setCount(0);
			Unity.shutdown();
		} catch (LauncherException e) {
			System.err.println("is implementation Error: "
					+ e.isImplementationError());
			e.printStackTrace(System.err);
		}
		System.out.println("done!");
	}
}
